#!/bin/bash
[ $# -eq 0 ] && { echo "Usage: $0 WORDSFILE"; exit 1; }

WORDSFILE=$1

# Experiments' settings
feature=bi
context=o2
space=vector
clmethod=direct
cluststop=pk2

cat $WORDSFILE | while read WORD
do
		prefix=$WORD-*
		resultsdir=Results-$prefix.$feature.$context.$clmethod.$cluststop
		
		#paste `ls Test-en*/$WORD/$resultsdir/$WORD-en*.cluster_solution.$cluststop` > FINAL-RESULTS/$WORD-solution.txt
		paste Test-en-es-fr/$WORD/$resultsdir/$WORD-en-es-fr.cluster_solution.$cluststop Test-en-es-it/$WORD/$resultsdir/$WORD-en-es-it.cluster_solution.$cluststop Test-en-es-pt/$WORD/$resultsdir/$WORD-en-es-pt.cluster_solution.$cluststop Test-en-fr-pt/$WORD/$resultsdir/$WORD-en-fr-pt.cluster_solution.$cluststop Test-en-it-fr/$WORD/$resultsdir/$WORD-en-it-fr.cluster_solution.$cluststop Test-en-it-pt/$WORD/$resultsdir/$WORD-en-it-pt.cluster_solution.$cluststop > FINAL-RESULTS/$WORD-solution.txt 
		# max=1

		# for i in {1..6}
		# do
		# 	count=tr -d -c '$i\n' < FINAL-RESULTS/$WORD-solution.txt | awk '{ print length; }'
		# 	if [ $count -gt $max ]; then
  # 				max=$count
		# 	fi
		# done

		# awk '{max=0;for(i=1;i<=NF;i++)if($i!~/NA/&&$i>max){max=$i;}count+=max;print max}' FINAL-RESULTS/$WORD-count.txt > FINAL-RESULTS/$WORD-final.txt
done